Surveys allow you to capture data from users in a form which can be reported on as survey results.
At the time of writing Kademi does not have a survey form builder, but you can use any html form. This guide shows you to create surveys (and polls)
First you need to create a "reward". A reward is a generic term which represents any competition, poll, survey, etc.
Select the Survey/Quiz check box on the Entry form tab
And be sure to make the survey "Active" in the status field. Then we're good to go!
So now lets have a form. Here's a very simple page to do that:
<html> <head> <title>Survey example</title> </head> <body> <h1>Survey form example</h1> <form action="/rewards/feedback-survey" class="surveyForm"> <input type="hidden" name="entry"/> <!-- This just flags the POST as an entry into the survey --> <input type="text" name="answer-favourite-colour" placeholder="Favourite color"/> <input type="text" name="answer-pet-name" placeholder="Pet's name"/> <button type="submit">Submit</button> </form> <script> $(function(){ $(".surveyForm").forms({ callback: function() { alert("Done!"); } }); }); </script> </body> </html>
There are three things to remember when creating the form:
- The form action should be /rewards/[reward name]
- The form must contain an input named "entry" to trigger the submission
- Fields you want to capture must have the prefix of "answer", for example name="answer-pet-name"
- get poll results by ajax, where you get a number of submissions for each answer
- get the answers for the current user by ajax
- get a list of all submissions in templating
/rewards/feedback-survey/_DAV/PROPFIND?fields=kademi:myAnswers
Similarly you can get poll results by requesting the pollResults (for single question polls) and allPollResults properties
You can access the entire list of submissions from templating like this:
#foreach( $sub in $page.submissions) $sub.profile.firstName - $sub.answers.get("answer-pet-name") #end
Ask a question, or offer an answer